package com.ruoyi.web.controller.workflow;

import java.util.List;
import java.util.Arrays;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.workflow.domain.BusStoreInfo;
import com.ruoyi.workflow.service.IBusStoreInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 养修预约Controller
 *
 * @author ruoyi
 * @date 2022-11-24
 */
@RestController
@RequestMapping("/workflow/info")
public class BusStoreInfoController extends BaseController {
    @Autowired
    private IBusStoreInfoService busStoreInfoService;

    /**
     * 查询养修预约列表
     */
    @PreAuthorize("@ss.hasPermi('workflow:info:list')")
    @GetMapping("/list")
    public TableDataInfo list(BusStoreInfo busStoreInfo) {
        startPage();
        List<BusStoreInfo> list = busStoreInfoService.selectBusStoreInfoList(busStoreInfo);
        return getDataTable(list);
    }

    /**
     * 导出养修预约列表
     */
    @PreAuthorize("@ss.hasPermi('workflow:info:export')")
    @Log(title = "养修预约", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BusStoreInfo busStoreInfo) {
        List<BusStoreInfo> list = busStoreInfoService.selectBusStoreInfoList(busStoreInfo);
        ExcelUtil<BusStoreInfo> util = new ExcelUtil<BusStoreInfo>(BusStoreInfo.class);
        util.exportExcel(response, list, "养修预约数据");
    }

    /**
     * 获取养修预约详细信息
     */
    @PreAuthorize("@ss.hasPermi('workflow:info:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(busStoreInfoService.getById(id));
    }

    /**
     * 新增养修预约
     */
    @PreAuthorize("@ss.hasPermi('workflow:info:add')")
    @Log(title = "养修预约", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BusStoreInfo busStoreInfo) {
        return toAjax(busStoreInfoService.save(busStoreInfo));
    }

    /**
     * 修改养修预约
     */
    @PreAuthorize("@ss.hasPermi('workflow:info:edit')")
    @Log(title = "养修预约", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BusStoreInfo busStoreInfo) {
        return toAjax(busStoreInfoService.updateById(busStoreInfo));
    }

    /**
     * 删除养修预约
     */
    @PreAuthorize("@ss.hasPermi('workflow:info:remove')")
    @Log(title = "养修预约", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        busStoreInfoService.updateStatus(ids);
        return AjaxResult.success("成功");
    }
}
